import { defHttp } from "/@/utils/http/axios"
import { Modal } from "ant-design-vue"


/**
 * 分页
 * @param params
 */
export const pageTenantPackage = (params) => {
  return defHttp.get({ url: "/iam-service/tenantPackage/page", params })
}

export const updateApp = (params) => {
  return defHttp.post({ url: "/iam-service/tenant/updateApp", params })
}

export const pageApp = (params) => {
  return defHttp.get({ url: "/iam-service/tenant/pageApp", params })
}

export const installApp = (params) => {
  return defHttp.post({ url: "/iam-service/tenant/installApp", params }, { joinParamsToUrl: true })
}

export const uninstallApp = (params) => {
  return defHttp.post({ url: "/iam-service/tenant/uninstallApp", params }, { joinParamsToUrl: true })
}

export const listTenantPackage = (params) => {
  return defHttp.get({ url: "/iam-service/tenantPackage/list", params })
}

/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdateTenantPackage = (params, isUpdate) => {
  const url = isUpdate ? "/iam-service/tenantPackage/update" : "/iam-service/tenantPackage/save"
  return defHttp.post({ url: url, params })
}

/**
 * 删除
 * @param params
 */
export const deleteTenantPackage = (params, handleSuccess) => {
  return defHttp.delete({ url: "/iam-service/tenantPackage/delete", data: params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess()
  })
}

/**
 * 批量删除
 * @param params
 */
export const batchDeleteTenantPackage = (params, handleSuccess) => {
  Modal.confirm({
    title: "确认删除",
    content: "是否删除选中数据",
    okText: "确认",
    cancelText: "取消",
    onOk: () => {
      return defHttp.delete({ url: "/iam-service/tenantPackage/deleteBatch", data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess()
      })
    },
  })
}
